package chart;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class City extends HttpServlet {

        public void destroy() {
        super.destroy(); 
        // Put your code here
    }

        public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        doPost(request,response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");
        String province=request.getParameter("province");
        PrintWriter out = response.getWriter();
        out.println("<response>");
        if(province.equals("1"))  
        {
            out.println("<city>");
            out.println("<cityname>Changsha</cityname>");
            out.println("<cityvalue>1</cityvalue>");
            out.println("</city>");
            
            out.println("<city>");
            out.println("<cityname>Loudi</cityname>");
            out.println("<cityvalue>2</cityvalue>");
            out.println("</city>");
            
            out.println("<city>");
            out.println("<cityname>Changde</cityname>");
            out.println("<cityvalue>3</cityvalue>");
            out.println("</city>");
        }else
        {

            out.println("<city>");
            out.println("<cityname>Guangzhou</cityname>");
            out.println("<cityvalue>1</cityvalue>");
            out.println("</city>");
            
            out.println("<city>");
            out.println("<cityname>Shenzhen</cityname>");
            out.println("<cityvalue>2</cityvalue>");
            out.println("</city>");
            
            out.println("<city>");
            out.println("<cityname>Foshan</cityname>");
            out.println("<cityvalue>3</cityvalue>");
            out.println("</city>");
        }
        out.println("</response>");
        
        out.flush();
        out.close();
    }

    public void init() throws ServletException {
        // Put your code here
    }

}